	<?php  ///// Get TEST from DB ///////////////////////////////////////////////////////////////////////
  function getTest() {
		  $db = mysqli_connect ("localhost", "lr12aas", "u3CJFB4r", "dblr12aas");
		  if (mysqli_connect_errno()) {
			  printf ("Connect failed: %s <br />",
			  mysqli_connect_error());
			  echo "<p class='crying'>Connection problem</p>";
			  exit ();
			  }
				  else {
			  echo "<p class='smiling'>Connected</p>";			
		  }
	  
	  $query= "SELECT * FROM test WHERE " . $_SERVER['QUERY_STRING'] . "";
		  $result = mysqli_query($db, $query);
  
		  if (!$result) {
		  return false;
			  }
	  
	  //check for rows
	  $numberOfRows = mysqli_num_rows($result);
	  if ($numberOfRows > 0) {
	  $fetchr= array();
	  
	  //get stuff out of the row
	  while ($row = mysqli_fetch_array($result)) {
	  $fetchr[] = $row;
		  }
	  return $fetchr;
		  } 		
	  }  
	  ?>
      <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Multiple Choice Assessment</title>
<link href="styles/styles.css" rel="stylesheet" type="text/css">
<script src="scripts/scripts.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
  <header>
    <h1>Choose Assessment</h1>
  </header>
  <section id="mainContent">
<a href="http://jose.cs.herts.ac.uk/lr12aas/public/new-prototype/choosetest.php?TestID=1">Test 1</a>
<a href="http://jose.cs.herts.ac.uk/lr12aas/public/new-prototype/choosetest.php?TestID=2">Test 2</a>
<?php
$getTest = getTest();
if ($getTest){
$TestID = $getTest[0][0];
$TestDescription = $getTest[0][1];
$wheretogo =$_GET['TestID'];
	echo "<p id='TestDescription'>" . $TestDescription . "</p>";
  	echo "<a href='index.php?ItemID=" . $wheretogo . "'" . ">GO</a>";
}
?>  
<a href="">Start Test</a>
</section>
  <footer></footer>
</div>



</body>
</html>

